package model;

import java.util.HashMap;
import java.util.List;
import java.util.Vector;

public class Graph {
	
	private HashMap<String,Module> modules = null;
	private HashMap<String,Relationship> relationships = null;
	private Vector<Relationship> relationshipsList = null;
	
	public HashMap<String,Module> getModules() {
		return modules;
	}
	public void setModules(HashMap<String,Module> modules) {
		this.modules = modules;
	}
	public List<Relationship> getRelationships() {
		return relationshipsList;
	}
	public void setRelationships(HashMap<String,Relationship> relationships) {
		this.relationships = relationships;
	}
	
	public void addModule(Module module) {
		if(this.modules == null){
			this.modules = new HashMap<String, Module>();
		}
		this.modules.put(module.getName(),module);
	}
	
	public Module getModule(String name) {		
		return modules.get(name);
	}
	
	public void addRelationship(Relationship relationship) {
		if(this.relationships == null){
			this.relationships = new HashMap<String, Relationship>();
			this.relationshipsList = new Vector<Relationship>();

		}
		String key = relationship.getSrcModule().getName() + "-" + relationship.getTargetModule().getName();
		this.relationships.put(key,relationship);
		this.relationshipsList.add(relationship);

	}
	
	public Relationship getRelationship(String srcModule, String targetModule){
		return relationships.get(srcModule + "-" + targetModule);
	}
	
}